package main

import (
	"adminSrv/dao"
	"adminSrv/handler"
	pb "adminSrv/proto"
	"github.com/asim/go-micro/plugins/registry/consul/v4"

	"go-micro.dev/v4"
	"go-micro.dev/v4/logger"
)

var (
	service = "adminsrv"
	version = "latest"
)

func main() {
	dao.InitDB()
	//注册服务
	consulReg := consul.NewRegistry()
	srv := micro.NewService(
		micro.Name(service),
		micro.Address("127.0.0.1:9090"),
		micro.Version(version),
		micro.Registry(consulReg),
	)

	// Register handler
	if err := pb.RegisterAdminSrvHandler(srv.Server(), new(handler.AdminSrv)); err != nil {
		logger.Fatal(err)
	}
	// Run service
	if err := srv.Run(); err != nil {
		logger.Fatal(err)
	}
}
